package com.yanggu.kylin;

import java.sql.*;

/**
 * @version V1.0
 * @author: YangGu
 * @date: 2020/6/15 17:46
 * @description:
 */
public class TesyKylin {

    public static void main(String[] args) throws ClassNotFoundException, SQLException {

        //kylin的jdbc驱动
        String KYLIN_DRIVER = "org.apache.kylin.jdbc.Driver";

        //kylin_url
        String KYLIN_URL = "jdbc:kylin://aliyun-hadoop102:7070/gmall";

        //username
        String USERNAME = "ADMIN";

        //password
        String PASSWORD = "KYLIN";

        //加载驱动
        Class.forName(KYLIN_DRIVER);

        //获取连接
        Connection connection = DriverManager.getConnection(KYLIN_URL, USERNAME, PASSWORD);

        PreparedStatement preparedStatement = connection.prepareStatement("select user_info.gender, sum(total_amount) from dwd_fact_order_detail order_detail left join dwd_dim_user_info_his_view user_info on order_detail.user_id = user_info.id group by user_info.gender;");

        ResultSet resultSet = preparedStatement.executeQuery();

        while (resultSet.next()) {
            System.out.println(resultSet.getString(1) + "---" + resultSet.getDouble(2));
        }
    }

}
